
package com.jml.s2pringIoc;

import org.springframework.context.support.ClassPathXmlApplicationContext;

@SuppressWarnings("resource")
public class SpringIocDemo {

	public static void main(String[] args) {
        //1.读取springxml配置
		ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
				"springioc.xml");
		//2.根据ID获取bean对象
		UserEntity userEntity = (UserEntity) classPathXmlApplicationContext.getBean("user1");
		System.out.println(userEntity.getUserId()+"----"+userEntity.getUserName());
		//2.1 根据ID获取bean对象
		UserEntity userEntity1 = (UserEntity) classPathXmlApplicationContext.getBean("user2");
		System.out.println(userEntity1.getUserId()+"----"+userEntity1.getUserName());
	}

}
